package com.huike.controller.adminController;


import com.baomidou.mybatisplus.extension.service.additional.query.impl.QueryChainWrapper;
import com.huike.entity.Menu;
import com.huike.service.IMenuService;
import com.huike.service.IRolesService;
import com.huike.utils.JsonUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Lwen
 * @since 2019-12-28
 */
@Controller
@RequestMapping("/admin/menu")
public class MenuController {

    @Autowired
    IMenuService menuService;

    /**
     * 获取用户的权限菜单
     * @param response
     * @param user_id
     */
    @RequestMapping("/getUserMenuByUserId")
    @ResponseBody
    public void getUserMenuByUserId(HttpServletResponse response,String user_id){
        List<Menu> userMenus = menuService.getUserMenuByUserId(user_id);
        JsonUtils.jsonArray(userMenus,response);
    }

    /**
     * 获取全部菜单
     */
    @RequestMapping("/getAllMenuList")
    @ResponseBody
    public void getAllMenuList(HttpServletResponse response){
        List<Menu> list = menuService.list();
        JsonUtils.jsonArray(list,response);
    }

}
